package com.ftg.elvis.controller;

import com.ftg.elvis.service.AdminMenuService;
import com.ftg.elvis.pojo.Menu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
@RequestMapping("/menu")
public class AdminMenuController {

	@Autowired
	AdminMenuService adminMenuService;

	@GetMapping("/showAll")
	public Map<String, Object> showAll(String username){
		String uid = adminMenuService.findId(username);
		Map<String, Object> map = new HashMap<>();
		List<Menu> data = adminMenuService.showAll(uid);
		map.put("data", data);
		map.put("code", 0);

		return map;
	}
}
